Skip to content

Conversation

@sharonkeikei
Copy link

Assignment Submission: Video Store API

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

If you didn't get to the functionality the question is asking about, reply with what you would have done if you had completed it.

Reflection

Prompt Response
Explain how you came up with the initial design of your ERD, based on the seed data and reading through the API endpoints We created a chart according to the relationships that we understood from the requirement and seed data, customer/ video will have many rentals and a rental belongs to one customer and one video. We decided to have a rental model because we want want to create a column for due_date.https://app.lucidchart.com/invitations/accept/fdd38d01-872f-48a5-a665-2c508cdbdbcc
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. We guess it would be O(n) since it has to render the entire customers/ videos list once.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. We think it would be O(1) since it is using the customer_id/ video_id to find the relative Rental instance.
Describe a specific set of positive and negative test cases you implemented for a model. A positive test case we used for video model is to provide all the required field and make sure that passed the validation, and for the negative test case, we set some required fields to nil to test that video won't be valid and return relevant errors messages.
Describe a specific set of positive and negative test cases you implemented for a controller. A positive case we have for rental controller is when a rental is successfully created, it will respond with 200 and increase the Rental.count by 1. And for the negative case, if the provided customer_id/ video_id doesn't exist, it will return not_found.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. API should respond with not_found / bad_request, instead of return 200 ok, like slack API.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We have the increment/decrement videos_checked_out_count, and increment/decrement available_inventory in the Rental.rb. We decided that is more related to the business logic so we put them in the model and call it from the controller.

@beccaelenzil
Copy link

Video Store API

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Practices git with at least 10 small commits and meaningful commit messages ✔️
Understands the importance of how APIs handle invalid/erroneous data in their reflection questions ✔️
Practices Rails best practices and well-designed separation, and encapsulates business logic around check-out and check-in in models ✔️
Uses controller tests to ensure quality code for every route, and checks for response status and content, with positive cases and negative cases ✔️
Uses controller tests to ensure correctness for check out and check in requirement, and that checked out counts and inventories appropriately change ✔️

Functional Requirements

Functional Requirement yes/no
All provided smoke tests for Wave 1 pass ✔️
All provided smoke tests for Wave 2 pass ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 3+ in Code Review && 2 in Functional Requirements ✔️

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this project! Your code is clear and well written. Your controllers are concise, and you've put the business logic in the model. Furthermore, your code is well tested. Keep up the hard work!

end

checkout = Rental.new(rental_params)
checkout.due_date = Date.today + 7.days

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very small amount of logic, but you might consider putting this logic into a custom model method.

@@ -0,0 +1,32 @@
frozen:
id: 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best practice to not include ids in fixtures. They will be automatically generated.




def increment_videos_checked_out_count
Copy link

@beccaelenzil beccaelenzil Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work putting all this logic into custom model methods. You might also consider whether any of this logic could go directly in the video and/or customer model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants